<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .echart{
            width: 500px;
            height: 500px;
        }
    </style>
</head>
<body>
折线图
<div class="echart allNumEchart"  id="allNumEchart"></div>
<script src="../jquery.min.js" charset="utf-8"></script>
<script src="../echarts.js"></script>
<script>
  //echarts未请求到数据
  function echartsNoDataTip(echartId) {
    $("#" + echartId).html('<div id="nodata" style="text-align: center;height:300px;line-height: 300px">未请求到数据...</div>');
    $('#' + echartId).removeAttr('_echarts_instance_');
  };
  //初始化echarts
  var myChartApplications;
  init();
  function init(){
    allNumEchart();//折线图
  };
  //折线图
  function allNumEchart() {
    /*逐年专利申请量-echart*/
    if (myChartApplications != null && myChartApplications != "" && myChartApplications != undefined) {
      myChartApplications.dispose();
    }
    var echartNameDataArr = []; //X轴名称
    var echartNumDataArr = []; //Y轴数量
    //列出标准列表-获得标准名字及专利数量
    // ajaxYearByDeclEntityList().then(function (yearList) {
    // console.log('tc', tcList);
    // for (var i = 0; i < tcList.length; i++) {
    var i = 0;
    // repeat();
    function repeat() {
      if (i < yearList.length) {
        if (yearList[i] <= sendData.staticAnalysisEnd.split('-')[0] && yearList[i] >= sendData.staticAnalysisStart.split('-')[0]) {
          ajaxCountByDeclEntity(yearList[i]).then(function (StandardNum) {
            // if (StandardList[i][2] != null && StandardList[i][2] != "" && StandardList[i][2] != undefined) {
            //   echartNameDataArr.push(StandardList[i][2].split('-')[0]); //截取年份字符串
            // } else {
            //   echartNameDataArr.push(StandardList[i][2]); //截取年份字符串
            // }
            echartNameDataArr.push(yearList[i]); //截取年份字符串
            echartNumDataArr.push(StandardNum);
            i++;
            repeat();
          });
        } else {
          i++;
          repeat();
        }
      } else {
        console.log('Standard', echartNameDataArr, echartNumDataArr);
        echartSetOption(); //构建标准分布 echarts
      }
    }
    echartSetOption();
    //构建标准分布 echarts
    function echartSetOption() {
      // 基于准备好的dom，初始化echarts实例
      myChartApplications = echarts.init(document.getElementById('allNumEchart'));
      // 指定图表的配置项和数据
      var option = {
        //标题及位置
        title: {
          text: 'Referer of a Website',
          // subtext: 'Fake Data',
          left: 'center',
          top: '30'
        },
        tooltip: {
          trigger: 'item'
        },
        //标签及位置
        legend: {
          type: 'scroll',
          orient: 'vertical',
          left: 'left',
          top: 'center',
          formatter: function (name) {
            // 标签过长处理
          var str = name.replace(/[^\x00-\xff]/g, "$&\x01")
          var strHtml = ''
          for (var i = 0; i < Math.ceil(str.length / 20); i++) {
            var strPat = str.substring(i * 20, (i + 1) * 20).replace(/.{20}\x01?/g, "$&\n").replace(/\x01/g, "")
            strHtml += '{a|' + strPat + '}'
          }
          if (str.length % 20 === 0) {
            strHtml = strHtml.substring(0, strHtml.lastIndexOf('\n')) + '}';
          }
          // console.log(strHtml);
          return strHtml;
        },
        textStyle: {
          rich: {
            a: {
              color: '#4C5058',
              // fontSize: 14,
              // fontWeight: 'bold',
              lineHeight: 18
            },
          }
        }
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            // radius: '50%',
            radius: ['20%', '50%'],//圆环
            avoidLabelOverlap: false,
            //圆角
            itemStyle: {
              borderRadius: 5,
              borderColor: '#fff',
              borderWidth: 2
            },
            //字体位置大小
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '16',
                fontWeight: 'bold'
              }
            },
            data: [
              { value: 1048, name: '第三方第三方的第三方第三方 Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              { value: 484, name: 'Union Ads' },
              { value: 300, name: 'Video Ads' }
            ],
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChartApplications.setOption(option);
    };
    // });
  };
</script>
</body>
</html>